<template>
	<view class="wrap">
		<view class="search">
			<u-search v-model="keywords" @custom="search" @search="search"></u-search>
		</view>
		<scroll-view class="scroll-list" scroll-y="true" @scrolltolower="loadMore">
			<u-cell-group class="list" :border="false">
				<u-swipe-action v-for="(item, index) in list" :key="item.id" :index="index" @click="optionsClick">
					<u-cell-item :arrow="true" @click="goPage(item.id,item)" style="border-bottom: 1px solid #ededed">
						<text slot="title">{{item.backlogContent || item.id}}</text>
						<view slot="label" style="padding-bottom:20rpx">发送时间：{{item.createDate}}</view>
						<view slot="label" style="padding-bottom:20rpx">发送人：{{item.sendUserName}}</view>
					</u-cell-item>
				</u-swipe-action>
			</u-cell-group>
			<view class="loadmore" @click="loadMore">
				<u-loadmore :status="loadStatus"></u-loadmore>
			</view>
		</scroll-view>
		<!-- <view class="btn-plus" @click="navTo('taskReceiveForm')">
			<u-icon name="plus-circle-fill" size="90" color="#3d87ff"></u-icon>
		</view> -->
	</view>
</template>
<script>
/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
export default {
	data() {
		return {
			keywords: '',
			query: {
				pageNo: 1,
				pageSize: 20
			},
			list: [],
			count: 0,
			loadStatus: 'loadmore',
			options: [
				{text: '删除', style: { background: '#dd524d'}}
			]
		};
	},
	onLoad() {
		this.loadList();
	},
	onShow() {
		if (uni.getStorageSync('refreshList') === true){
			uni.removeStorageSync('refreshList');
			this.search('');
		}
	},
	methods: {
		goPage(id,item){
			let type = item.bizType
			if(type=='task_receive'){//跳任务接收
				uni.navigateTo({
					url: '/pages/task/taskReceive/taskReceiveForm?id='+item.actionId
				});
			}else if(type=='task_audit_arrange'){//跳任务整理审核
				uni.navigateTo({
					url: '/pages/task/taskAuditArrange/taskAuditArrangeForm?id='+item.bizKey
				});
			}else if(type=='task_audit_deploy'){//跳任务部署审核
				uni.navigateTo({
					url: '/pages/task/taskAudit/taskAuditForm?id='+item.bizKey
				});
			}else if(type=='task_audit_feedback'||type=='task_confirm'){//跳任务反馈审核-任务反馈部署人审核,任务反馈科室成员审核
				uni.navigateTo({
					url: '/pages/task/taskAuditFeedback/taskAuditFeedbackForm?id='+item.bizKey
				});
			}else if(type=='task_yuqi'||type=='task_transfer'||type=='task_feedback'){//跳任务反馈-任务逾期,任务转办,反馈审核驳回
				uni.navigateTo({
					url: '/pages/task/taskFeedback/taskFeedbackDetail?actionId='+item.actionId
				});
			}else{
				uni.navigateTo({
					url: '/pages/sys/msg/form2?id=' + id
				});
			}
			
		},
		loadMore() {
			this.loadStatus = "loading";
			setTimeout(() => {
				this.query.pageNo += 1;
				this.loadList();
			}, 100);
		},
		loadList() {
			this.query.dataStatus="1"
			this.$u.api.message.list2(this.query).then(res => {
				if (!res.list || res.list.length == 0){
					this.loadStatus = "nomore";
					return;
				}
				this.list = this.list.concat(res.list);
				this.count = res.count;
				this.query.pageNo = res.pageNo;
				this.query.pageSize = res.pageSize;
				this.loadStatus = "loadmore";
			});
		},
		search(value) {
			this.query.taskTitle=value
			this.list = [];
			this.query.pageNo = 0;
			this.query.testInput = value;
			this.loadList();
		},
		navTo(url) {
			uni.navigateTo({
				url: url
			});
		}
	}
};
</script>
<style lang="scss">
page {
	background-color: #f8f8f8;
}
.btn-plus {
	position: absolute;
	bottom: 50rpx;
	right: 50rpx;
	z-index: 1;
	opacity: 0.6;
}
.btn-plus:hover {
	opacity: 1;
}
</style>
